package com.mifengs.mall.floor;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.annotation.ItemProviderTag;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.mifengs.mall.R;
import com.mifengs.mall.adapter.GridQuickAdapter;
import com.mifengs.mall.entity.AdvertBean;
import com.mifengs.mall.entity.BannerBean;
import com.mifengs.mall.entity.FloorBean;
import com.mifengs.mall.loader.GlideImageLoader;
import com.mifengs.mall.util.ImageLoadUtil;
import com.mifengs.mall.util.ToIntentUtil;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lynn on 2018/4/19.
 */

@ItemProviderTag(
        viewType = FloorListAdapter.TYPE_TWENTY_TWO,
        layout = R.layout.fragment_three_floor
)
public class FloorTwentyTwoItemProvider extends BaseItemProvider<FloorBean,BaseViewHolder> {
    private GridQuickAdapter mGridQuickAdapter;

    @Override
    public void convert(BaseViewHolder viewHolder, final FloorBean floorBean, int index) {
        RecyclerView mRecyclerView =  viewHolder.getView(R.id.grid_list);
        Banner banner = viewHolder.getView(R.id.banner);
        if(floorBean !=null){
            mRecyclerView.setLayoutManager(new GridLayoutManager(mContext,3));
            mRecyclerView.setNestedScrollingEnabled(false);
            mGridQuickAdapter= new GridQuickAdapter(R.layout.item_grid,floorBean.getAdverts(),mContext);
            mRecyclerView.setAdapter(mGridQuickAdapter);
            mGridQuickAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
                @Override
                public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                    AdvertBean adverts = floorBean.getAdverts().get(position);
                    ToIntentUtil.toCommonIntent(adverts.getActionUrl(),mContext);
                }
            });
        }
    }

    @Override
    public void onClick(BaseViewHolder baseViewHolder, FloorBean floorBean, int i) {

    }

    @Override
    public boolean onLongClick(BaseViewHolder baseViewHolder, FloorBean floorBean, int i) {
        return false;
    }
}
